<div id="company_tb">
	<a href="#" onclick="add()" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
	<a href="#" onclick="edit()" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">编辑</a>
	<a href="#" onclick="del()" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
</div>
<table id="company_dg"></table>
<#include "/WEB-INF/views/include/common.ftl"/>
<script>
	var company_fg;
	$(function() {
		company_fg = $('#company_dg');
		company_fg.datagrid({
			url: '${ctx}/offer/companyList',
			fitColumns: true,
			pagination: true,
            rownumbers: true,
            singleSelect:true,
			pageSize: 10,
			pageList: [10, 20, 30],
            idField: 'id',
			columns: [
				[{
                    field: 'id',
                    width: 100,
                    hidden: true,
                    title: 'id'
				},{
					field: 'companyName',
					title: '公司名称',
					width: 100
				}, {
					field: 'companyRange',
					title: '支付产品',
					width: 100
				}, {
					field: 'companyMoney',
					title: '注册资金',
					width: 100,
                    formatter: function(value,row,index){
                       return value + "万";
                    }
                }, {
					field: 'companyCreateTime',
					title: '合作时间',
					width: 100
				}, {
					field: 'companyAddress',
					title: '公司地址',
					width: 100
				},{
					field: 'uploadFile',
                    title:'文件',
                    width: 100,
                    formatter: function(value,row,index){
                        return "<a href='#' onclick='upload("+row.id+")'>上传</a> <a href='#' onclick='downloadFile("+row.id+")'>下载</a>";
                    }
				}]
			],
			toolbar: '#company_tb'
		});
	})

	<!--添加方法-->
	function add() {
		parent.$.modalDialog.openner = company_fg;
		parent.$.modalDialog({
			title: "添加公司",
			width: 300,
			height: 300,
			href: "${ctx}/offer/addCompanyUI"
		});
	}

	<!--编辑方法-->
    function edit(){
        parent.$.modalDialog.openner = company_fg;
        var selectrow = company_fg.datagrid("getSelected");
        if(selectrow == null){
            $.messager.show({
                title : '提示信息',
                msg : '请选择一条记录',
                timeout : 1000 * 2
            });
            return false;
        }
        parent.$.modalDialog({
            title: "编辑支付公司信息",
            width: 300,
            height: 300,
            href: "${ctx}/offer/editCompanyUI/"+selectrow.id
        });
    }

	function del(){
        var selectrow = company_fg.datagrid("getSelected");
        if(selectrow == null){
            $.messager.show({
                title : '提示信息',
                msg : '请选择一条记录',
                timeout : 1000 * 2
            });
            return false;
        }

        $.get("${ctx}/offer/delCompany/"+selectrow.id,function(data){
            company_fg.datagrid("reload");
            $.messager.show({
                title : '提示信息',
                msg : '操作成功',
                timeout : 1000 * 2
            });
        })
	}

	/**
	 * 文件上传
	 */
	function upload(id){
        parent.$.modalDialog.openner = company_fg;
        parent.$.modalDialog({
            title: "上传文件",
            width: 300,
            height: 200,
            href: "${ctx}/offer/uploadfileUI/"+id
        });
	}

	/**
	 * 文件下载
	 */
	function downloadFile(id){
        parent.$.modalDialog.openner = company_fg;
        parent.$.modalDialog({
            title: "下载文件",
            width: 400,
            height: 250,
            href: "${ctx}/offer/downloadFileUI/"+id
        });
	}
</script>